﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;

using SimpleForum.Data.Models;
using SimpleForum.Data.Repositories;
using SimpleForum.Classes.Core.Extensions;

namespace SimpleForum.Classes.Core.Providers
{
    public class PrincipalProvider : IPrincipal
    {
        public IIdentity Identity { get; private set; }
        private readonly IRepository<User> UserRepository;

        public PrincipalProvider(IIdentity Identity)
        {
            this.Identity = Identity;
            this.UserRepository = new Repository<User>(new DatabaseContextContainer());
        }

        public bool IsInRole(string Role)
        {
            var User = UserRepository.Get().GetUserByEmail(Identity.Name);

            if(User != null)
            {
                return true;
            }

            return false;
        }
    }
}